// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Invincibility Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

// Aliases
private alias 30 : TYPE_INVINCIBILITY


// Static Values

// Tables
public table Invincibility_table33
	7, 4, 6, 4, 4, 6, 4, 7, 4, 6, 6, 4
end table

public table Invincibility_table32
	2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 3, 4, 5, 6, 7
	6, 5, 4, 3
end table

public table Invincibility_table31
	1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4
	5, 6, 7, 6, 5, 4, 3, 2
end table

public table Invincibility_table30
	0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3
	4, 5, 6, 5, 4, 3, 2, 1
end table


event ObjectMain
	if object.state == 0
		object.value7 = object[-playerCount].xpos
		object.value6 = object[-playerCount].xpos
		object.value5 = object[-playerCount].xpos
		object.value4 = object[-playerCount].xpos
		object.value3 = object[-playerCount].xpos
		object.value2 = object[-playerCount].xpos
		object.value1 = object[-playerCount].xpos
		object.value0 = object[-playerCount].xpos
		object.value15 = object[-playerCount].ypos
		object.value14 = object[-playerCount].ypos
		object.value13 = object[-playerCount].ypos
		object.value12 = object[-playerCount].ypos
		object.value11 = object[-playerCount].ypos
		object.value10 = object[-playerCount].ypos
		object.value9 = object[-playerCount].ypos
		object.value8 = object[-playerCount].ypos
		object.value16 = 180
		object.value17 = 0
		object.state = 1
		object.inkEffect = INK_ALPHA
		object.alpha = 255
		object.drawOrder = -1
	end if
	object.value19++
	object.value19 %= 12
	object.value20++
	object.value20 %= 10
	object.value7 = object.value6
	object.value6 = object.value5
	object.value5 = object.value4
	object.value4 = object.value3
	object.value3 = object.value2
	object.value2 = object.value1
	object.value1 = object.value0
	object.value0 = object[-playerCount].xpos
	object.value15 = object.value14
	object.value14 = object.value13
	object.value13 = object.value12
	object.value12 = object.value11
	object.value11 = object.value10
	object.value10 = object.value9
	object.value9 = object.value8
	object.value8 = object[-playerCount].ypos
	if object[-playerCount].direction == FLIP_NONE
		object.value16 += 144
		object.value16 &= 511
		object.value17 += 16
		object.value17 &= 511
	else
		object.value16 -= 144
		object.value16 &= 511
		object.value17 -= 16
		object.value17 &= 511
	end if
	if object[-playerCount].value7 < 32
		object.alpha = object[-playerCount].value7
		object.alpha <<= 3
	end if
end event


event ObjectDraw
	temp2 = object.value17
	temp2 += 116
	Cos(temp0, temp2)
	Sin(temp1, temp2)
	temp0 <<= 11
	temp1 <<= 11
	temp0 += object.value7
	temp1 += object.value15
	GetTableValue(object.frame, object.value19, Invincibility_table30)
	DrawSpriteFX(object.frame, FX_INK, temp0, temp1)
	temp2 = object.value17
	temp2 += 372
	Cos(temp0, temp2)
	Sin(temp1, temp2)
	temp0 <<= 11
	temp1 <<= 11
	temp0 += object.value7
	temp1 += object.value15
	temp2 = object.value19
	temp2 += 6
	GetTableValue(object.frame, temp2, Invincibility_table30)
	DrawSpriteFX(object.frame, FX_INK, temp0, temp1)
	Cos(temp0, object.value17)
	Sin(temp1, object.value17)
	temp0 <<= 11
	temp1 <<= 11
	temp0 += object.value5
	temp1 += object.value13
	GetTableValue(object.frame, object.value19, Invincibility_table31)
	DrawSpriteFX(object.frame, FX_INK, temp0, temp1)
	temp2 = object.value17
	temp2 += 256
	Cos(temp0, temp2)
	Sin(temp1, temp2)
	temp0 <<= 11
	temp1 <<= 11
	temp0 += object.value5
	temp1 += object.value13
	temp2 = object.value19
	temp2 += 6
	GetTableValue(object.frame, temp2, Invincibility_table31)
	DrawSpriteFX(object.frame, FX_INK, temp0, temp1)
	temp2 = object.value17
	temp2 += 168
	Cos(temp0, temp2)
	Sin(temp1, temp2)
	temp0 <<= 11
	temp1 <<= 11
	temp0 += object.value3
	temp1 += object.value11
	GetTableValue(object.frame, object.value20, Invincibility_table32)
	DrawSpriteFX(object.frame, FX_INK, temp0, temp1)
	temp2 = object.value17
	temp2 += 424
	Cos(temp0, temp2)
	Sin(temp1, temp2)
	temp0 <<= 11
	temp1 <<= 11
	temp0 += object.value3
	temp1 += object.value11
	temp2 = object.value20
	temp2 += 5
	GetTableValue(object.frame, temp2, Invincibility_table32)
	DrawSpriteFX(object.frame, FX_INK, temp0, temp1)
	Cos(temp0, object.value16)
	Sin(temp1, object.value16)
	temp0 <<= 11
	temp1 <<= 11
	temp0 += object[-playerCount].xpos
	temp1 += object[-playerCount].ypos
	GetTableValue(object.frame, object.value19, Invincibility_table33)
	DrawSpriteFX(object.frame, FX_INK, temp0, temp1)
	temp2 = object.value16
	temp2 += 256
	Cos(temp0, temp2)
	Sin(temp1, temp2)
	temp0 <<= 11
	temp1 <<= 11
	temp0 += object[-playerCount].xpos
	temp1 += object[-playerCount].ypos
	DrawSpriteFX(object.frame, FX_INK, temp0, temp1)
end event


event ObjectStartup
	LoadSpriteSheet("Global/Items.gif")
	SpriteFrame(0, 0, 1, 1, 232, 42)
	SpriteFrame(0, 0, 1, 1, 233, 42)
	SpriteFrame(-1, -1, 3, 3, 232, 41)
	SpriteFrame(-2, -2, 5, 5, 232, 35)
	SpriteFrame(-3, -3, 7, 7, 232, 27)
	SpriteFrame(-4, -4, 9, 9, 232, 17)
	SpriteFrame(-7, -7, 15, 15, 232, 1)
	SpriteFrame(-15, -15, 31, 31, 200, 1)
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
